package com.everyday.practice.thread;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @description: 顺序打印
 * @author: leon
 * @time: 2021/4/6 9:39
 */
public class Title1114 {
    public volatile int flag=1;
    class Foo {
        public void first() {
            Thread.yield();
            System.out.println("first");
        }
        ReentrantLock lock=new ReentrantLock();
        Condition condition=lock.newCondition();
        public void second() {
            System.out.println("second");
        }

        public void third() {
            System.out.println("third");
        }
    }


    public void first(Runnable printFirst) throws InterruptedException {

        // printFirst.run() outputs "first". Do not change or remove this line.
        printFirst.run();
    }

    public void second(Runnable printSecond) throws InterruptedException {

        // printSecond.run() outputs "second". Do not change or remove this line.
        printSecond.run();
    }

    public void third(Runnable printThird) throws InterruptedException {

        // printThird.run() outputs "third". Do not change or remove this line.
        printThird.run();
    }
}
